package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqPurchasedetails;
import com.drug.mingkang.Mapper.HqPurchasedetailsMapper;
import com.drug.mingkang.service.HqPurchasedetailsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 采购明细(HqPurchasedetails)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:43
 */
@Service("hqPurchasedetailsService")
public class HqPurchasedetailsServiceImpl implements HqPurchasedetailsService {
    @Resource
    private HqPurchasedetailsMapper hqPurchasedetailsMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param detailsId 主键
     * @return 实例对象
     */
    @Override
    public HqPurchasedetails queryById(String detailsId) {
        return this.hqPurchasedetailsMapper.queryById(detailsId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqPurchasedetails> queryAllByLimit(int offset, int limit) {
        return this.hqPurchasedetailsMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqPurchasedetails 实例对象
     * @return 实例对象
     */
    @Override
    public HqPurchasedetails insert(HqPurchasedetails hqPurchasedetails) {
        this.hqPurchasedetailsMapper.insert(hqPurchasedetails);
        return hqPurchasedetails;
    }

    /**
     * 修改数据
     *
     * @param hqPurchasedetails 实例对象
     * @return 实例对象
     */
    @Override
    public HqPurchasedetails update(HqPurchasedetails hqPurchasedetails) {
        this.hqPurchasedetailsMapper.update(hqPurchasedetails);
        return this.queryById(hqPurchasedetails.getDetailsId());
    }

    /**
     * 通过主键删除数据
     *
     * @param detailsId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String detailsId) {
        return this.hqPurchasedetailsMapper.deleteById(detailsId) > 0;
    }
}